﻿using Company.IO.Interfaces;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Company.System.IO.IntegrationTests
{
    /// <summary>
    ///This is a test class for FileTest and is intended
    ///to contain all FileTest Unit Tests
    ///</summary>
    [TestClass]
    public partial class FileTest : TestBase<IFile>
    {
        private const string _SStringNull = null;
        private const string _SLocalPath = ".\\";
        private static string _classRoot;
        private IDirectory _directory;
        private string _testRoot;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        [ClassInitialize]
        public static void ClassInit(TestContext context)
        {
            _classRoot = global::System.IO.Path.GetFullPath(
                string.Format("{0}Company.System.IO.IntegrationTests\\DirectoryTest\\",
                              global::System.IO.Path.GetTempPath()));

            if (global::System.IO.Directory.Exists(_classRoot))
            {
                global::System.IO.Directory.Delete(_classRoot, true);
            }
            global::System.IO.Directory.CreateDirectory(_classRoot);
        }

        [ClassCleanup]
        public static void ClassCleanup()
        {
        }

        [TestInitialize]
        public void Initialize()
        {
            _testRoot = string.Format("{0}{1}\\", _classRoot, TestContext.TestName);
            if (global::System.IO.Directory.Exists(_testRoot))
            {
                global::System.IO.Directory.Delete(_testRoot, true);
            }

            global::System.IO.Directory.CreateDirectory(_testRoot);

            _directory = CreateTestDirectory(_testRoot);
        }

        [TestCleanup]
        public void CleanUp()
        {
        }

        private static IDirectory CreateTestDirectory(string currentDir)
        {
            IDirectory directory = new Directory();

            directory.SetCurrentDirectory(currentDir);

            return directory;
        }
    }
}